package com.example.aussiehealthhelper;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.button.MaterialButton;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MaterialButton drugBtn = findViewById(R.id.btnDrug);
        MaterialButton healthNotesBtn = findViewById(R.id.btnHealthNotes);
        MaterialButton exchangeBtn = findViewById(R.id.btnExchange);
        MaterialButton commonPhonesBtn = findViewById(R.id.btnCommonPhones);
        MaterialButton toolsBtn = findViewById(R.id.btnTools);

        //按钮点击
        drugBtn.setOnClickListener(v -> navigateToDrugSearch());
        healthNotesBtn.setOnClickListener(v -> navigateToHealthNotes());
        exchangeBtn.setOnClickListener(v -> navigateToExchange());
        commonPhonesBtn.setOnClickListener(v -> navigateToCommonPhones());
        toolsBtn.setOnClickListener(v -> showToolsToast());
    }

    private void navigateToDrugSearch() {
        Intent intent = new Intent(this, DrugSearchActivity.class);
        startActivity(intent);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }

    private void navigateToHealthNotes() {
        Intent intent = new Intent(this, HealthNotesActivity.class);
        startActivity(intent);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }

    private void navigateToExchange() {
        Intent intent = new Intent(this, ExchangeActivity.class);
        startActivity(intent);
        overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
    }

    private void navigateToCommonPhones() {
        Intent intent = new Intent(this, CommonPhonesActivity.class);
        startActivity(intent);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }

    private void showToolsToast() {
        Toast.makeText(this, "更多实用工具正在开发中...", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    }
}